#include "streamrd.h"
#include <fstream.h>
#include <conio.h>

class FileReader : public StreamReader
{
	int bold_;
public:
	FileReader();
	void test(int showMarkup);
}

FileReader::FileReader() : StreamReader(), bold_(0)
{
	clrscr();
}

void FileReader::test(int showMarkup)
{
	int c = 0;

	resetInputStream();
	textcolor(LIGHTGRAY);
	while (c != EOF) {
		c = getChar();
		if (c == '<' & bold_ == 0) {
			textcolor(WHITE);
			bold_ = 1;
			if (showMarkup)
				putBackChar(c);
			continue;
		} else if (c == '>' & bold_ == 1) {
			textcolor(LIGHTGRAY);
			bold_ = 0;
			if (showMarkup)
				putBackChar(c);
			continue;
		}
		if (c != EOF)
			putch(c);
	}
}

int main()
{
	ifstream input;
	FileReader reader;

	input.open("sample.txt", ios::binary | ios::in);
	reader.setInputStream(&input);
	reader.test(0);
	reader.test(1);
	return 0;
}
